
/*
 * @项目名称: 模板开发
 * @FilePath: /meek/src/utils/image.js
 * @Author: 
 * @Date: 2021-02-05T15:26:07+08:00
 * @LastEditors: 
 * @LastEditTime: 2021-02-05T15:26:07+08:00
 * Copyright (c) 2018-2022 
 */
                                                    
export function rotateCanvas(context, viewRotation) {
  let x = context.canvas.width;
  let y = context.canvas.height;
  const rotation = Math.floor(viewRotation);
  if ( rotation === 0 ) {
    context.translate(0, 0);
  } else if ( rotation == 1 ) {
    context.translate((x - y) / 2, (x + y) / 2);
  } else if ( rotation == 3 ) {
    context.translate(x, y);
  } else {
    context.translate((x + y) / 2, (y - x) / 2);
  }

  context.rotate(-viewRotation)
}
